<div class="box">
  <div class="box-header " style="position: relative;">
    
    <ob_link><a class="btn" href="{:url('staffRelationAdd')}"><i class="fa fa-plus"></i> 新 增</a></ob_link>
    &nbsp;
    <ob_link><a class="btn export" url="{:url('exportstaffrelation')}" ><i class="fa fa-download"></i> 员 工 导 出</a></ob_link>
    <ob_link><a class="btn dataimport" url="{:url('staffImport',array('type'=>'0'))}" ><i class="fa fa-arrow-circle-o-up"></i> 员 工 导 入</a></ob_link>
  <!-- </div> -->
    <!-- <ob_link><a class="btn export" url="{:url('aduitStaff')}"><i class="fa fa-download"></i> 审 核</a></ob_link> -->
    <div class="box-header ajax-form searchAll">
      <div class="col-md-3 col-sm-3 col-3">
          <label>姓名<input type="text" name="staff_name" value="{:input('staff_name')}" class="form-control form-control-sm ajax-form-value" placeholder="请输入姓名" ></label>
      </div>
      <div class="col-md-3 col-sm-3 col-3">
          <label>手机号<input type="text" name="phones" value="{:input('phones')}" class="form-control form-control-sm ajax-form-value" placeholder="请输入手机号" ></label>
      </div>
      <div class="col-md-3 col-sm-3 col-3">
          <label>身份证号<input type="text" name="card_id" value="{:input('card_id')}" class="form-control form-control-sm ajax-form-value" placeholder="请输入姓名" ></label>
      </div>
      <div class="col-md-3 col-sm-3 col-3">
          <label>入职时间<input type="text" name="entry_time" value="{:input('entry_time')}" readonly="readonly" style="cursor:pointer"  class="form-control test-item ajax-form-value" placeholder="请选择时间" ></label>
      </div>
      
      
      <div class="col-md-3 col-sm-3 col-3">
          <label>公司名<select class="form-control form-control-sm ajax-form-value" name="company_id" id="company_list">
            <option value="">请选择公司名</option>
            {volist name='company_list' id='vo'}
                <option value="{$vo['id']}" {if input('company_id') == $vo['id']} selected="selected" {/if} >{$vo['name']}</option>
            {/volist}
          </select></label>
      </div>
      <div class="col-md-3 col-sm-3 col-3">
          <label>部门名<select class="form-control form-control-sm ajax-form-value" name="branch_id" id="branch_list">
            <option value="">请选择部门名</option>
            {if condition="$branch_id neq 0"}
            {volist name='branch_list' id='vo'}
                <option value="{$vo['id']}" {if input('branch_id') == $vo['id']} selected="selected" {/if} >{$vo['branch_name']}</option>
            {/volist}
            {if condition="$branch_id neq 0"}
          </select></label>
      </div>

      <div class="col-md-3 col-sm-3 col-3">
          <label>组名<select class="form-control form-control-sm ajax-form-value" name="group_id" id="group_list">
            <option value="">请选择组名</option>
            {if condition="$group_id neq 0"}
            {volist name='group_list' id='vo'}
                <option value="{$vo['id']}" {if input('group_id') == $vo['id']} selected="selected" {/if} >{$vo['group_name']}</option>
            {/volist}
            {if condition="$group_id neq 0"}
          </select></label>
      </div>
      <div class="col-md-1 col-sm-1 col-1">
          <div class="btn-group pull-right" style="margin-top:20px;margin-right:20px">
              <a href="javascript:;" id="searchAll" class="btn btn-default"  url="{:url('staffRelation')}">
                  搜索<i class="fa fa-search"></i>
              </a>
          </div>
      </div>
      <div class="col-md-1 col-sm-1 col-1">
        <div class="btn-group pull-right" style="margin-top:20px;margin-right:20px">
            <a href="javascript:;" id="searchclear" class="btn btn-default">
                重置<i class="fa fa-history"></i>
            </a>
        </div>
    </div>

    </div>
    <br/>
  </div>
    
  <div class="box-body table-responsive">
    <table  class="table table-bordered table-hover">
      <thead>
      <tr>
          <th>姓名</th>
          <th>公司</th>
          <th>部门</th>
          <th>手机号</th>
          <th>身份证</th>
          <th>入职时间</th>
          <!-- <th>试用薪资</th> -->
          <th>入职岗位</th>
          <th>状态</th>
          <th>操作</th>
      </tr>
      </thead>
      
      {notempty name='list'}
        <tbody>
            {volist name='list' id='vo'}
                <tr>
                  <td>{$vo.staff_name}</td>
                  <td>{$vo.name}</td>
                  <td>{$vo.branch_name}</td>
                  <td>{$vo.phones}</td>
                  <td>{$vo.card_id}</td>
                  <td>{$vo.entry_time}</td>
                  <!-- <td>{$vo.probationpay}</td> -->
                  <td>{$vo.position}</td>
                  <td>
                    {if condition="$vo['w_status'] eq 1"}<span class="badge bg-red"> 待入职</span>{else/}<span class="badge bg-green"> 已入职</span> {/if}</td>
                  <td class="text-center">
                      <ob_link><a href="{:url('staffRelationEdit', array('id' => $vo['id']))}" class="btn" style="padding:2px 5px"><i class="fa fa-edit"></i> 编 辑</a></ob_link>
                      &nbsp;
                      <ob_link><a class="btn layerDel"  style="padding:2px 5px" url="{:url('staffRelationDel', array('id' => $vo['id']))}" href="javascript:void(0)"><i class="fa fa-trash-o"></i> 删 除</a></ob_link>
                      &nbsp;
                      <ob_link><a class="btn layerAudit"  style="padding:2px 5px" url="{:url('staffWorkAudit', array('id' => $vo['id'],'w_status'=>$vo['w_status']))}" href="javascript:void(0)" id="{$vo['w_status']}"><i class="fa fa-gavel"></i> 入 职</a></ob_link>
                  </td>
                </tr>
            {/volist}
        </tbody>
        {else/}
        <tbody><tr class="odd"><td colspan="8" class="text-center" valign="top">{:config('empty_list_describe')}</td></tr></tbody>
      {/notempty}
    </table>
  </div>

  <div class="box-footer clearfix text-center">
      {$list->render()}
  </div>

</div>
<script src="__STATIC__/module/admin/laydate/laydate.js"></script>
<script src="__STATIC__/module/admin/laydate/layer.js"></script>
<script>
  $('#company_list').change(function(){
    var options=$(this).children("option:selected");
    var company_id=options.val();
    $('#branch_list option').remove();
    $('#group_list option').remove();
     $("#group_list").append("<option value='6'>请选择组名</option>");
     $("#branch_list").append("<option value=''>请选择部门名</option>");
    $.post('/admin/branch/branchlist',{company_id:company_id},function(data){
      $(data.data).each(function(index,item){ 
          var option="<option value="+item.id+">"+item.branch_name+"</option>"
          $("#branch_list").append(option);  
            // console.log(item); 
        }); 
    });  
  })

  $('#branch_list').change(function(){
    var options=$(this).children("option:selected");
     options.attr('selected','selected'); 
    var branch_id=options.val();
    $('#group_list option').remove();
     $("#group_list").append("<option value='6'>请选择组名</option>");
    // alert(branch_id);
    $.post('/admin/group/grouplist',{branch_id:branch_id},function(data){
      $(data.data).each(function(index,item){ 
          var option="<option value="+item.id+">"+item.group_name+"</option>"
          $("#group_list").append(option);  
            console.log(item); 
        }); 
    });  
  })
    //导出功能
    $(".export").click(function(){
        
        window.location.href = searchAllFormUrl($(".export"));
    });
//搜索条件重置
    $('#searchclear').click(function(){
      $('.form-control').val('');
      window.location.href = searchAllFormUrl('#searchAll');
    })
    $('.dataimport').click(function(){
      url=$(this).attr('url');
      layer.open({
        type: 2,
        shade: false,
        title: false, //不显示标题
        content:url, //捕获的元素
        area: ['480px','200px']
      });
    })
    // 时间插件
    lay('.test-item').each(function(){
      laydate.render({
        elem: this
        ,trigger: 'click'
        // ,type: 'month' //日期格式
      });
   });

    $('.layerDel').click(function(){
      var target =$(this).attr('url');
      layer.confirm('您确定要删除吗？', {
        btn: ['确认','取消'] //按钮
      }, function(){
        $.get(target).success(function(data){
          layer.closeAll();
          obalert(data);
        });
      })
    })

     $('.layerAudit').click(function(){
      var target =$(this).attr('url');
      var id=$(this).attr('id')
      var msg='';
      if(id==1){
        msg='您确定员工已入职吗？'
      }else{
        msg='您确定员工未入职吗？'
      }
      layer.confirm(msg, {
        btn: ['确认','取消'] //按钮
      }, function(){
        $.get(target).success(function(data){
          layer.closeAll();
          obalert(data);
        });
      })
    })
</script>